#version 460
#extension GL_GOOGLE_include_directive : enable

#include "../../../../core/shader_color.h"
#include "../../../../core/shader_tranform.h"
#include "../../../../core/shader_widget_panel.h"
#include "../../../../core/shader_widget_color.h"



layout(location = 0) in vec2 inPos;
layout(location = 1) in vec2 inWeights;
layout(location = 2) in vec2 inNormal;

layout(location = 0) out vec4 vColor;
//layout(location = 1) out VS_GS_VERTEX {
//	uint vInstance;
	//uint vVertexIndex;
//}vertex_out;

//vec2 pos[4] = {vec2(10.0, 10.0), vec2(100.0, 10.0), vec2(10.0, 100.0), vec2(100.0, 100.0)};
void main(void){
	mat3x2 mat = m_LP_SD[gl_InstanceIndex];

	switch(m_GradientNum) {
	case 0:
		gl_Position = vec4(inPos, 0.0, 1.0);
		break;
	case 1:
		gl_Position = vec4(inPos.yx, 0.0, 1.0);
		break;
	}
	
	gl_Position.xy *= mat[1];
	gl_Position.xy *= mat[2];
	
	//gl_Position.x *= m_Scale.x;
	//gl_Position.xy += mat[0];
	gl_Position.x += m_Loc.x - (int(m_Loc.x / mat[2].x) >> 1 << 1) * mat[2].x;
	
	
	gl_Position.x = round(gl_Position.x) + 0.5;
	gl_Position = mat_ProjecView * gl_Position;
	vColor = f_glsl_buildColor(InstanceColor[gl_InstanceIndex]);
	float i = 0;
	float coA = modf(float(gl_VertexIndex)/4.0f, i);
	float coB = modf(float(max(0, gl_VertexIndex-1))/4.0f, i);
	if(coA <= 0 || coB <= 0 ){
		vColor.rgb *= 0.5;
	}
	
	gl_PointSize = 4.0;

	
}


